﻿<UserControl x:Class="TreeBuilder.ArrowLink"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ctrl="clr-namespace:Elderos.Controls;assembly=Elderos.Controls"
             xmlns:local="clr-namespace:TreeBuilder"
             xmlns:cp="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <local:ThicknessConverter x:Key="ThicknessConverter"/>
    </UserControl.Resources>
    <UserControl.ContextMenu>
        <ContextMenu Name="Menu" Closed="Menu_Closed" Opened="Menu_Opened"
            HorizontalContentAlignment="Stretch">
            <MenuItem>
                <MenuItem.Header>
                    <cp:ColorPicker Name="ColorPicker" VerticalContentAlignment="Stretch" SelectedColorChanged="ColorPicker_OnSelectedColorChanged"/>
                </MenuItem.Header>
            </MenuItem>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="4*"/>
                </Grid.ColumnDefinitions>
                <Label Content="Thickness:" DockPanel.Dock="Left"/>
                <ctrl:ValidatableTextBox
                    DockPanel.Dock="Right"
                    Grid.Column="1"
                    MinWidth="30"
                    Text="{Binding ElementName=MainPath,Path=StrokeThickness, Mode=TwoWay,Converter={StaticResource ThicknessConverter}}"
                    TextChanged="TextBox_TextChanged"
                    Validate="ValidateDouble" FinalValidation="ValidateThickness" DefaultValue="1"
                        />
            </Grid>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="4*"/>
                </Grid.ColumnDefinitions>
                <Label Content="Dashes:"/>
                <ctrl:ValidatableTextBox
                    Grid.Column="1"
                    Text="{Binding ElementName=MainPath,Path=StrokeDashArray, Mode=TwoWay}"
                    Validate="ValidateDoubleCollection" FinalValidation="ParseDoubleCollection" DefaultValue=""                    
                    MinWidth="30"
                        />
            </Grid>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="4*"/>
                </Grid.ColumnDefinitions>
                <Label Content="Vertical offset:"/>
                <ctrl:ValidatableTextBox Name="VerticalOffsetBox" Style="{StaticResource ValidatableBoxStyle}" Grid.Column="1"
                        Text="" Validate="ValidateDouble" FinalValidation="ParseDouble" DefaultValue="0"
                        MinWidth="30"
                        />
            </Grid>
            <MenuItem Name="DeleteMenuItem" Header="Delete" Click="DeleteMenuItem_Click">
                <MenuItem.Icon>
                    <Image Source="pack://application:,,,/Icons/delete.png"></Image>
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
    </UserControl.ContextMenu>
    <Path Name="MainPath" StrokeThickness="1" Loaded="MainPath_OnLoaded" MouseLeftButtonUp="MainPath_OnMouseLeftButtonUp"
          Fill="Transparent">
        <Path.Data>
            <GeometryGroup x:Name="GeometryGroup" FillRule="EvenOdd">
                <LineGeometry x:Name="FromLine" StartPoint="0,0" EndPoint="0,100"/>
                <PathGeometry x:Name="ArcPath" FillRule="EvenOdd">
                    <PathFigure x:Name="ArcFigure" StartPoint="0,100" >
                        <PathSegmentCollection>
                            <ArcSegment x:Name="ArcSegment" Point="100,100" Size="1,1"/>
                        </PathSegmentCollection>
                    </PathFigure>
                </PathGeometry>
                <LineGeometry x:Name="ToLine" StartPoint="{Binding ElementName=ArcSegment, Path=Point}" EndPoint="100,0"
                              />
            </GeometryGroup>
        </Path.Data>
    </Path>
</UserControl>
